package JDBC.Day10_Spring.JDBCTemplate;

import JDBC.Day10_Spring.utils.JDBCUtils;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.Scanner;

/**
 *  JdbcTemplate 入门
 */
public class JDBCTemplateDemo1 {
    public static void main(String[] args) {
        //1. 导入jar包 -- 五个
        //2. 创建JdbcTemplate对象
        JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
        //3. 调用方法
        String sql = "insert into emp values(null , ?, ?, ?, ?, ?, ?, ?)";
        Scanner inInt = new Scanner(System.in);
        Scanner inString = new Scanner(System.in);
        String ename = inString.nextLine();
        int job_id = inInt.nextInt();
        int mgr = inInt.nextInt();
        String joindate = inString.nextLine();
        double salary = inInt.nextDouble();
        double bonus = inInt.nextDouble();
        int dept_id = inInt.nextInt();
        int count = template.update(sql, ename, job_id, mgr, joindate, salary, bonus, dept_id);
        System.out.println(count);

        // 会自动归还和释放资源
    }
}
